package com.ning.run.web.controller.response;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @Description: Controller层统一结果相应
 * @Author:ning
 * @Email:cxy_ning@163.com
 * @Date:2022/11/20 20:13
 **/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class R<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    private String msg;

    private T data;

    R(T data){
        this.data = data;
    }
    R(String msg){
        this.msg = msg;
    }

    public static R success(){
        return new R("执行成功!!!");
    }
    public static <T> R<T> success(T data){
        return new R("执行成功!!!",data);
    }
    public static <T> R<T> success(T data,String msg){
        return new R(msg,data);
    }
    public static R failure(){
        return new R("操作失败!!!");
    }
    public static <T> R<T> failure(T data){
        return new R("操作失败!!!",data);
    }
    public static <T> R<T> failure(T data,String msg){
        return new R(msg,data);
    }
}
